<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/3/1 0001
  Time: 16:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品分类</title>
    <jsp:include page="../base.jsp"/>

    <!-- bootstrap-表格搭建 -->
    <link rel="stylesheet" href="${requestScope.webRoot}static/bootstrap/table/bootstrap-table.min.css">
    <script src="${requestScope.webRoot}static/bootstrap/table/bootstrap-table.min.js" ></script>
    <script src="${requestScope.webRoot}static/bootstrap/table/locale/bootstrap-table-zh-CN.min.js" ></script>

    <!-- 表单验证 -->
    <script type="text/javascript" src="${requestScope.webRoot}static/js/jquery/jquery.form.js"></script>
    <link rel="stylesheet" href="${requestScope.webRoot}static/bootstrap/validator/bootstrapValidator.min.css">
    <script src="${requestScope.webRoot}static/bootstrap/validator/bootstrapValidator.min.js"></script>

    <link rel="stylesheet" href="${requestScope.webRoot}static/css/theme.css">

    <script src="${requestScope.webRoot}static/js/control/modal/hintModal.js"></script>
    <script src="${requestScope.webRoot}static/js/control/select/Select.js"></script>
    <script src="${requestScope.webRoot}static/js/control/img/selectImage.js"></script>
    <script src="${requestScope.webRoot}static/js/control/table/FoodTypeTable.js"></script>
    <script src="${requestScope.webRoot}static/js/control/form/BootstrapValidateBaseForm.js"></script>
    <script src="${requestScope.webRoot}static/js/control/form/FoodTypeForm.js"></script>
    <script src="${requestScope.webRoot}static/js/control/form/FoodTypeTransferForm.js"></script>
</head>
<body>
<jsp:include page="../leftTheBorder.jsp">
    <jsp:param name="level1Menu" value="food"/>
    <jsp:param name="level2Menu" value="foodtype"/>
</jsp:include>
<div class="mainContent">
    <div class="segmentation-1">食品分类管理</div>
    <div class="bootstrap-table-div" data-userId="${sessionScope.user.id}" style="min-width: 700px"></div>
</div>
<!-- 添加更新数据的modal -->
<div class="modal fade modalPanel" tabindex="-1" id="foodTypeModal">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <form class="form-horizontal" role="form" enctype="multipart/form-data" method="post">
                <div class="form-group">
                    <label class="col-sm-3 control-label">图片:</label>
                    <div class="col-sm-9">
                        <input class="form-control" type="file" name="picurl" style="display:none;"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">名称:</label>
                    <div class="col-sm-9">
                        <input class="form-control" type="text" name="typename"/>
                    </div>
                </div>
                <div class="form-group">
                    <div>
                        <button class="back col-sm-4 col-sm-offset-2 col-xs-4 col-xs-offset-2  btn btn-default" type="button" >返回</button>
                        <button class="submit col-sm-4 col-sm-offset-1 col-xs-4 col-xs-offset-1 btn btn-primary" type="button" >提交</button>
                    </div>
                </div>
                <input type="hidden" name="typeid">
                <%--<input type="hidden" name="userId" value="${sessionScope.user.id}">--%>
            </form>
        </div>
    </div>
</div>
<!-- 转移分类的modal -->
<div class="modal fade modalPanel" tabindex="-1" id="FoodTypeTransferModal">
    <div class="modal-dialog" style="width: 400px;">
        <div class="modal-content">
            <form class="form-horizontal" role="form" method="post">
                <input type="hidden" name="typeId">
                <div class="form-group">
                    <label class="col-sm-3 control-label">转移到:</label>
                    <div class="col-sm-9">
                        <select class="form-control" data-live-search="true" name="targetTypeId"></select>
                    </div>
                </div>
                <div class="form-group">
                    <div>
                        <button class="back col-sm-4 col-sm-offset-2 btn btn-default" type="button" >返回</button>
                        <button class="submit col-sm-4 col-sm-offset-1 btn btn-primary" type="button" >提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="error"></div>
<script>
    $(function () {
        window.tableObject =  new FoodTypeTable($(".bootstrap-table-div"),"foodtype");
        window.foodTypeSelect = '${foodtype}';

        /* 添加更新数据的modal */
        tableObject.foodtypeForm = new FoodTypeForm({
            $modal:$("#foodTypeModal"),
            $error:$("#error"),
            table:tableObject
        });
        /* 图片选择框 */
        $("[name='picurl']").selectImage();

        /* 转移分类的modal */
        tableObject.foodtypeTransferForm = new FoodTypeTransferForm({
            $modal: $("#FoodTypeTransferModal"),
            $error:$("#error"),
            table: tableObject
        });
        <!-- 下拉单 -->
        var $user = tableObject.foodtypeTransferForm.param("targetTypeId");//部门select
//        alert(foodTypeSelect);
        Select.injectData($user,foodTypeSelect, "typeid","typename", "--请选择--", 0);
    });
</script>
</body>
</html>
